package com.rongshu.view.penpal.present;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.utils.Common;
import com.rongshu.utils.UserInfoUtils;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.base.mvp.INetView;
import com.rongshu.view.penpal.bean.PenpalResponse;
import com.rongshu.view.penpal.bean.RecommendPenpalResponse;

import java.util.HashMap;
import java.util.Map;

import rx.Subscriber;
import rx.functions.Action0;

/**
 * created by zhengweis on 2018/11/22.
 * description：
 */
public class PenpalSearchPresenter extends BasePresenter<INetView> {

    public PenpalSearchPresenter(Context context) {
        super(context);
    }

    public void searchPenpalList(String content, int pageIndex, int pageSize) {
        Map<String, Object> map = new HashMap<>();
        map.put("user_id", UserInfoUtils.getUserId());
        map.put("label", "");
        map.put("penclubname", content);
        map.put("district", "");
        map.put("pageIndex", pageIndex);
        map.put("pageSize", pageSize);
        RetorfitService.getPenPalListByKeyword(UserInfoUtils.getUserId(), "", content, "", pageIndex, pageSize,
                Common.encryptionSign(map)).doOnSubscribe(new Action0() {
            @Override
            public void call() {

            }
        }).subscribe(new Subscriber<PenpalResponse>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(PenpalResponse object) {
                getView().success(object, 0);
            }
        });
    }
}
